<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Home</title>
    <link rel="stylesheet" th:href="@{static/css/layui.css}">
    <style>
        .demo {
            width: 1060px;
            /* margin: 0 auto; */
        }

        .layui-input {
            width: 800px;
        }

        .tijiao {
            margin-left: 1250px;
        }
    </style>
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">运动会管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">

        </ul>
        <ul class="layui-nav layui-layout-right">
            <div th:if="${session.user}">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-user" style="font-size: 15px"></i>
                        <span th:text="${session.user.getNum()}">unknown</span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd th:if="${session.user.getIdentity().equals('2')}"><a th:href="@{userinfo}">基本资料</a></dd>
                        <dd><a th:href="@{/toPage(url=rePassword)}">修改密码</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="user/logout">退出</a></li>
            </div>
            <div th:unless="${session.user}">
                <li class="layui-nav-item"><a th:href="@{/toPage(url=login)}">登录</a></li>
            </div>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="test" style="margin-right: 10px;">
                <li class="layui-nav-item"><a href="/sports">主页</a></li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">当前赛况</a>
                    <dl class="layui-nav-child">
                        <dd><a th:href="@{/toPage(url=scoreSituation)}">田赛</a></dd>
                        <dd><a th:href="@{/toPage(url=scoreSituationJ)}">径赛</a></dd>
                    </dl>
                </li>
                <div th:if="${session.user}">
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('2')}"><a th:href="@{/toPage(url=signup)}">我要报名</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('2')}"><a th:href="@{/toPage(url=myRegistration)}">我的报名</a></li>
                    <li class="layui-nav-item layui-nav-itemed" th:if="${session.user.getIdentity().equals('0') || session.user.getIdentity().equals('1')}">
                        <a href="javascript:;">上传成绩</a>
                        <dl class="layui-nav-child">
                            <dd><a th:href="@{/toPage(url=scoreEntryT)}">田赛</a></dd>
                            <dd><a th:href="@{/toPage(url=scoreEntryJ)}">径赛</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=registrationReview)}">报名审核</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=perManagement)}">人员管理</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=noticeManage)}">公告管理</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=volunteer)}">志愿者名单</a></li>
                    <li class="layui-nav-item" th:if="${session.user.getIdentity().equals('1')}"><a th:href="@{/toPage(url=projectManage)}">项目</a></li>
                </div>
            </ul>
        </div>
    </div>

        <div class="layui-col-md4 layui-col-md-offset5">
            <h1 style="height: 70px;margin-top: 40px">新建公告</h1>
        </div>

        <form class="layui-form" action="notice/newNotice" method="post" style="margin-left:200px;margin-top: 40px;">
            <div class="layui-form-item">
                <label class="layui-form-label">标 题 :</label>
                <div class="layui-input-block">
                    <input type="text" name="title" required lay-verify="required" placeholder="请输入标题"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">时 间 :</label>
                <div class="layui-input-block">
                    <input type="text" name="time" required lay-verify="required" placeholder="请输入时间" autocomplete="off"
                           class="layui-input" id="time">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">作 者 :</label>
                <div class="layui-input-block">
                    <input type="text" name="author" required lay-verify="required" placeholder="请输入作者"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">内 容 :</label><br/><br/>
                <div style="width: 1500px;margin-left: 50px; ">
                <textarea id="lay_edit" name="detail" class="demo" lay-verify="content"
                          style="display: none;"></textarea>
                </div>
            </div>

            <div class="layui-form-item" style="margin-top: 30px;">
                <div class="layui-input-block tijiao">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

</div>

<script th:src="@{static/layui.js}" charset="utf-8"></script>

<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#time' //指定元素
        });
    });
</script>


<script>
    layui.use(['layedit', 'form'], function () {
        var form = layui.form;
        var layedit = layui.layedit;
        var $ = layui.$;
        layedit.set({    //设置图片接口
            uploadImage: {
                url: 'file/upload'
                , type: 'post' //默认post
            }
        });
        //创建一个编辑器
        var index = layedit.build('lay_edit', {
            height: 450
        });
        //提交时把值同步到文本域中
        form.verify({
            //content富文本域中的lay-verify值
            content: function (value) {
                return layedit.sync(index);
            }
        });
        //提交
        form.on("submit(formDemo)", function (data) {
            try {


                $.ajax({
                    url: "notice/newNotice",
                    contentType: "application/json",
                    type: 'POST',
                    data: JSON.stringify(data.field),
                    async: false,
                    dataType: 'text',
                    cache: false,
                    success: function (result) {
                        if (result == "success") {
                            layer.msg("创建成功");
                            window.location.href = "/sports/toPage?url=noticeManage";
                        } else {
                            layer.msg("创建失败");
                        }
                    },
                    error: function (e) {
                        layer.msg("服务器好像出了问题，请稍后再试");
                    }
                });
            } catch (e) {
                console.log(e)
            }

            return false;
        });
    });
</script>

<script>
    layui.use('element', function () {
        var element = layui.element;
        //监听导航点击
        element.on('nav(test)', function (elem) {
        });
    });
</script>


</body>

</html>